﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Bootshishen
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int blackWidth = 0, blackHeight = 0, alphaHeight = 0;
            try
            {
                blackWidth = Int32.Parse(textBoxBlackWidth.Text);
                blackHeight = Int32.Parse(textBoxBlackHeight.Text);
                alphaHeight = Int32.Parse(textBoxAlphaHeight.Text);
            }
            catch (FormatException ex)
            {
                MessageBox.Show("图片尺寸相关参数格式错误", "错误");
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误");
                return;
            }
            int width = blackWidth;
            int height = blackHeight + alphaHeight;
            Bitmap bmp = new Bitmap(width, height);
            Graphics g = Graphics.FromImage(bmp);
            Brush brush = new SolidBrush(Color.Black);
            g.Clear(Color.Transparent);
            g.FillRectangle(brush, new Rectangle(0, 0, width, blackHeight));

            DialogResult dr = saveFileDialog.ShowDialog();
            if (dr == DialogResult.OK)
            {
                bmp.Save(saveFileDialog.FileName);
                MessageBox.Show("生成完成", "提示");
            }
        }
    }
}
